{include file='public/head'}
{include file='public/left'}
<!-- content -->

<div class="main_02_r">

    <!--内容区域-->
    <div class="site_01">
        <span>当前位置：</span><a href="#">城事社</a><i>></i><a href="#">角色管理</a><i>></i><a href="#">商家管理</a>
    </div>

    <div class="nrq_01">
        <div class="gg_01">
            <span><a href="{:url('user/index')}">用户管理</a></span><span class="on">商家管理</span>
        </div>
        <div class="gg_02">
            <div class="gg_03">
                <div class="gg_03_t">
                    <a href="javascript:void(0);" class="a1 fwzs_click">服务设置</a>
                    <em class="fr">
                        <form method="get">
                        <input type="text" value="{$search|default=''}" placeholder="请输入有关分类信息的关键词" class="gg_03_txt" /><input type="button" value="" class="gg_03_btn" />
                        </form>
                    </em>
                </div>

                <div class="flxx_01 layer-photos-demo" id="layer-photos-demo" >
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <th>序号</th>
                            <th>商家头像</th>
                            <th>商家名称</th>
                            <th>入驻分类</th>
                            <th>商家地址</th>
                            <th>联系电话</th>
                            <th>营业时间</th>
                            <th>商家简介</th>
                            <th>商家服务</th>
                            <th>商家封面</th>
                            <th>营业执照</th>
                            <th>到期日期</th>
                            <th>操作</th>
                        </tr>
                        {volist name="arr" id="vo"}
                        <tr >
                            <td>{$vo.id}</td>
                            <td><img src="{$vo.merchant_avatar}" class="img_01" /></td>
                            <td>{$vo.merchant_name}</td>
                            <td>{$vo.classify_first_name} - {$vo.classify_second_name}</td>
                            <td>{$vo.merchant_address}</td>
                            <td>{$vo.merchant_mobile}</td>
                            <td>{$vo.open_hours}</td>
                            <td>{$vo.merchant_profile|mb_substr=0,10,'utf-8'}</td>
                            <td>{$vo.merchant_server}</td>
                            <td><img height="36px" width="68" src="{$vo.merchant_cover}" layer-src="{$vo.merchant_cover}" class="img_02" /></td>
                            <td><img height="36px" width="68" src="{$vo.license_url}" layer-src="{$vo.license_url}" class="img_02" /></td>
                            <td>{$vo.due_date}</td>
                            <td>
                                {if condition="$vo.state == 1"}
                                <a href="javascript:ajax_merchant_pass('{$vo.id}',2)" class="a1">审核</a>
                                <a href="javascript:ajax_merchant_pass('{$vo.id}',3)" class="a1">拒绝</a>
                                {elseif condition="$vo.state == 2"}
                                <a class="a1">已通过</a>
                                {elseif condition="$vo.state == 3"}
                                <a class="a1">未通过</a>
                                {/if}
                                <a href="javascript:ajax_merchant_delete('{$vo.id}')" class="a1">删除</a>
                            </td>
                        </tr>
                        {/volist}
                    </table>
                </div>

                <div class="gg_03_b">
                    <div class="fl">
                        <span>共 <i>{$arr->total()}</i> 条</span><span>每页 <i>{$arr->listRows()}</i> 条</span>
                    </div>
                    <div class="fr">
                        {$arr->render()}
                    </div>
                </div>
            </div>
        </div>

    </div>

</div>

<!--服务设置弹窗-->
<div class="fwsz_fr">
    <div class="ggtcxq_bg"></div>
    <div class="ggtcxq_c">
        <div class="ggtcxq_cfr">
            <div class="ggtcxqc_t">
                <span>服务设置</span><a href="javascript:void(0);" class="close"></a>
            </div>
            <div class="fwzs_c">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <th>序号</th>
                        <th>服务名称</th>
                        <th>显隐</th>
                        <th>操作</th>
                    </tr>
                    {volist name="merchant_serve" id="serve"}
                    <tr>
                        <td>{$serve.id}</td>
                        <td class="td1">
                            <em><input name="server" id="serve_{$serve.id}" maxlength="4" type="text" value="{$serve.serve|default=''}" class="fwzs_txt" />
                                <input  type="button" onclick="ajax_serve_edit('{$serve.id}')" class="fwzs_btn" /></em>
                        </td>
                        <td class="td2 flxx_click">
                            <em value="{$serve.id}" class="{if condition='$serve.show_flag == 0'}on{/if}"><b></b></em>
                        </td>
                        <td>
                            <a href="#" value="{$serve.id}" class="fwzs_cz"></a>
                        </td>
                    </tr>
                    {/volist}

                </table>
                <script type="text/javascript">
                    $(".flxx_click").each(function () {
                        $(this).find("em").click(function () {
                            var id = $(this).attr('value');
                            if ($(this).attr("class") != "on") {
                                $(this).addClass("on");
                                ajax_show("{:url('user/ajax_serve_show')}",{"show":0,"id":id});
                            }
                            else {
                                $(this).removeClass("on");
                                ajax_show("{:url('user/ajax_serve_show')}",{"show":1,"id":id});
                            }
                        });
                    });
                </script>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(".fwzs_click").click(function () {
        $(".fwsz_fr").show();
        $(".fwsz_fr .ggtcxq_c").css({ "margin-top": "-" + $(".fwsz_fr .ggtcxq_c").height() / 2 + "px" });
    });
    $(".fwsz_fr .close").click(function () {
        $(".fwsz_fr").hide();
    });
    $(".fwsz_fr .ggtcxq_bg").click(function () {
        $(".fwsz_fr").hide();
    });
</script>
<script>
    //调用示例
    layer.photos({
        photos: '#layer-photos-demo'
        ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
    });

    function ajax_serve_edit(id) {
        var serve = $("#serve_"+id).val();
       ajax_psot("{:url('user/ajax_serve_edit')}",{"id":id,"serve":serve});
    }

    function ajax_merchant_delete(id) {
        ajax_psot("{:url('user/ajax_merchant_delete')}",{"id":id});
    }

    function ajax_merchant_pass(id,pass) {
        ajax_psot("{:url('user/ajax_merchant_pass')}",{"id":id,"pass":pass});
    }

    function ajax_show(url,data){
        $.ajax({
            url:url,
            type: "POST",//方法类型
            // dataType: "json",//预期服务器返回的数据类型
            data: data,
            success: function (data) {
                if (data.code === 1) {
                    layer.msg("<span style='margin-left: 18px;'>"+data.msg+"</span>",{icon: 1,time:1000},function(){
                        //window.location.href=data.url;
                    });
                }else{
                    layer.msg("<span style='margin-left: 18px;'>"+data.msg+"</span>",{icon: 2,time:1000},function(){
                        /*if(data.url){
                            window.location.href=data.url;
                        }else{
                            location.reload();
                        }*/
                    });
                }
            },
            error : function() {
                layer.msg("<span style='margin-left: 18px;'>请求错误,请联系管理员</span>",{icon: 0,time:1000},function(){
                    //location.reload();
                });
            }
        });
    }

    function ajax_psot(url,data){
        $.ajax({
            url:url,
            type: "POST",//方法类型
            // dataType: "json",//预期服务器返回的数据类型
            data: data,
            success: function (data) {
                if (data.code === 1) {
                    layer.msg("<span style='margin-left: 18px;'>"+data.msg+"</span>",{icon: 1,time:1000},function(){
                        window.location.href=data.url;
                    });
                }else{
                    layer.msg("<span style='margin-left: 18px;'>"+data.msg+"</span>",{icon: 2,time:1000},function(){
                        /*if(data.url){
                            window.location.href=data.url;
                        }else{
                            location.reload();
                        }*/
                    });
                }
            },
            error : function() {
                layer.msg("<span style='margin-left: 18px;'>请求错误,请联系管理员</span>",{icon: 0,time:1000},function(){
                    //location.reload();
                });
            }
        });
    }

</script>

<!-- content -->
{include file='public/foot'}